home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Browsers, Managers & Extensions / Mozilla Weave 0.2.7 / latest-weave.xpi / modules / xmpp / readme.txt < prev    next >
Text File  |  2008-07-08  |  6KB  |  126 lines

  1. About the XMPP module
  2.  
  3. Here is sample code demonstrating how client code can use the XMPP module.
  4. It assumes that a Jabber server capable of HTTP-Polling is running on localhost
  5. on port 5280.
  6.  
  7.         Components.utils.import( "resource://weave/xmpp/xmppClient.js" );
  8.  
  9.         var serverUrl = "http://127.0.0.1:5280/http-poll";
  10.         var jabberDomain = "mylaptop.local";
  11.  
  12.         var transport = new HTTPPollingTransport( serverUrl,
  13.                                                                         false,
  14.                                             4000 );
  15.         // "false" tells the transport not to use session keys.  4000 is the number of
  16.         // milliseconds to wait between attempts to poll the server.
  17.         var auth = new PlainAuthenticator();
  18.         var alice = new XmppClient( "alice", jabberDomain, "iamalice",
  19.                                                  transport, auth );
  20.         // This sets up an XMPP client for the jabber ID 
  21.         // "alice@jonathan-dicarlos-macbook-pro.local", who has password
  22.         // "iamalice".
  23.  
  24.         // Set up callback for incoming messages:
  25.         var aliceMessageHandler = {
  26.             handle: function( msgText, from ) {
  27.                 // Your code goes here.  It will be called whenever another XMPP client
  28.                    // sends a message to Alice.
  29.                    // msgText is the text of the incoming message, and "from" is the
  30.            // jabber ID of the sender.
  31.             }
  32.         };
  33.         alice.registerMessageHandler( aliceMessageHandler );
  34.  
  35.         // Connect
  36.         alice.connect( jabberDomain );
  37.         alice.waitForConnection();
  38.         // this will block until our connection attempt has either succeeded or failed.
  39.         // Check if connection succeeded:
  40.         if ( alice._connectionStatus == alice.FAILED ) {
  41.             // handle error
  42.         }
  43.  
  44.         // Send a message
  45.         alice.sendMessage( "bob@mylaptop.local", "Hello, Bob." );
  46.  
  47.     // Disconnect
  48.     alice.disconnect();
  49.  
  50.  
  51. Installing an XMPP server to test against:
  52.  
  53. I'm using ejabberd, which works well and is open source but is implemented in Erlang.  (That's bad, because I don't know how to hack Erlang.  I'm thinking of moving to jabberd, implemented in C.)
  54.  
  55. ejabberd: http://www.ejabberd.im/
  56. jabberd: http://jabberd.jabberstudio.org/
  57.  
  58. Installation of ejabberd was simple.  After it's installed, configure it (create an admin account, and enable http-polling) by editing the configuration file:
  59.  
  60.         ejabberd/conf/ejabberd.cfg
  61.  
  62.  Its web admin interface can be used to create accounts (so that the "alice" and "bob" accounts assumed by the testing code will actually exist).  This admin interface is at:
  63.  
  64.         http://localhost:5280/admin/
  65.  
  66. The ejabberd process is started simply by running:
  67.  
  68.         ejabberd/bin/ejabberdctl start
  69.  
  70.  
  71. Outstanding Issues -- bugs and things to do.
  72.  
  73. * The test above is failing with a timeout.  How to debug this?  Let's start
  74.    by making it two processes again and seeing if that makes a difference...
  75.  
  76.    Nope.  It doesn't.  Bob just gets an HTTP status 0
  77.  
  78. * Occasionally (by which I mean, randomly) the server will respond to
  79.    a POST with an HTTP status 0.  Generally things will go back to
  80.    normal with the next POST and then keep working, so it's not
  81.    actually preventing anything from working, but I don't understand
  82.    what status 0 means and that makes me uncomfortable as it could be
  83.    hiding other problems.
  84.  
  85.    What if I modify the sending code to repeat the sending of any messages
  86.    that result in HTTP status 0?
  87.    -- seems to work, but doesn't help.  (It's not HTTP status 0 that's preventing
  88.    the test from passing...)
  89.  
  90. * Occasionally (randomly) a message is received that has a raw integer
  91.   for a messageElem, which causes XML parsing of the incoming message
  92.   to fail.  I don't see any pattern for the values of the raw
  93.   integers, nor do I understand how we can get an integer in place of
  94.   an XML element when requesting the root node of the incoming XML
  95.   document.
  96.  
  97. * Duplicate messages.  Occasionally, even though one instance of the
  98.   client sends only a single copy of a <message> stanza, the intended
  99.   target will receive it multiple times.  Sometimes if the recipient
  100.   signs off and then signs back on, it will recieve another copy of
  101.   the message.  This makes me think it's probably a feature of the
  102.   server to resend messages that it thinks the recipient might have
  103.   missed while offline.  Duplicate messages are a problem especially
  104.   when using xmpp to synchronize two processes, for instance.  Do I
  105.   need to tweak the server settings, or change server implementations?
  106.   Do I need to have the client receiving messages acknowledge them to the
  107.   server somehow?
  108.   Do I need to move to using <iq> stanzas for synchronization?  Or
  109.   start putting GUIDs into <message>s and discarding duplicates
  110.   myself?
  111.  
  112. * Whenever I send an <iq> request, I get a <bad-request/> error back
  113.   from the server.  Documentation for the standard error messages
  114.   indicates that bad-request is supposed to happen when the type of
  115.   the iq element is invalid, i.e. something other than 'set', 'get',
  116.   'result', or 'error'.  But I'm using 'get' or 'set' and still
  117.   getting <bad-request/>.  I don't understand what's happening here.
  118.  
  119. * The authentication layer currently doesn't work with MD5-digest auth, only plain
  120.    auth.
  121.  
  122. * The HTTPPolling transport layer gets a "key sequence error" if useKeys is turned on.
  123.    (Everything seems to be working OK with useKeys turned off, but that's less
  124.    secure.)
  125.  
  126.